<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .blue {
      color: blue;
    }

    .red {
      color: red;
    }
  </style>
</head>

<body>
  <div id="app">
    双向绑定演示：{{str}}<br />
    v-model演示：<input type="text" v-model='dog.name' /><br />
    多层级属性演示：{{dog.name}} <br />
    <p v-bind:class='className' class="abc">
      动态class功能演示
    </p>
    计算属性演示：{{getComputedValue}}<br />
    点击事件演示：<button v-on:click='clickBtn'>点我试试</button>
  </div>
  <script src="./dependency.js"></script>
  <script src="./observer.js"></script>
  <script src="./watch.js"></script>
  <script src="./compiler.js"></script>
  <script src="./vue.js"></script>
  <script type="text/javascript">
    let vue = new Vue({
      el: '#app',
      data: {
        str: '你好Vue',
        dog: {
          name: '二哈'
        },
        className: 'blue'
      },
      watch: {
        str() {
          console.log('data.str被改了，最新值' + this.str)
        }
      },
      computed: {
        getComputedValue() {
          return this.str + ' ' + '呵呵'
        }
      },
      methods: {
        clickBtn(e) {
          console.log(e.target.textContent, e)
        }
      }
    })
    window.vue = vue
    setTimeout(function () {
      this.vue._data.className = 'red'
      this.vue._data.str = '你好世界'
    }, 3000)
  </script>
</body>

</html>